<?php
// +----------------------------------------------------------------------
// | webhooks
// +----------------------------------------------------------------------
// | Author: King east <1207877378@qq.com>
// +----------------------------------------------------------------------


namespace ke;


use FastRoute\DataGenerator\GroupCountBased;
use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
use FastRoute\RouteParser\Std;
use ke\route\RouteGroup;
use ke\route\RouteHandle;
use ke\route\RouteItem;

// 'get', 'post', 'patch', 'put', 'delete', 'head

/**
 * Class Route
 * @package ke
 * @method static RouteItem rule($rule, $controller)
 * @method static RouteItem get($rule, $controller)
 * @method static RouteItem post($rule, $controller)
 * @method static RouteItem patch($rule, $controller)
 * @method static RouteItem put($rule, $controller)
 * @method static RouteItem delete($rule, $controller)
 * @method static RouteItem head($rule, $controller)
 * @method static displatch()
 * @method static group(array $options, callable $callback)
 */
class Route
{
    /**
     * @var RouteCollector $route
     */
    static $route;

    public static function init()
    {
        static::$route = new RouteHandle();
    }


    public static function __callStatic($name, $arguments)
    {
        if (in_array($name, array_merge(RouteHandle::$METHODS, ['displatch', 'group']))) {
            return call_user_func_array([self::$route, $name], $arguments);
        }
    }


}